package com.wiz.web.controllor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wiz.web.service.LoginService;

@Controller
@RequestMapping("/login")
public class LoginControllor extends BaseControllor{
	private transient final Logger log = LoggerFactory.getLogger(getClass());
	
	@Resource
	private LoginService loginService;
	
	@RequestMapping(value = "/activate", method = RequestMethod.POST)
	@ResponseBody
	public String activate(HttpServletRequest request,
			@RequestParam(value = "stationMac") String stationMac,
			@RequestParam(value = "stationId") String stationId,
			@RequestParam(value = "activationCode") String activationCode,
			HttpSession session, Model model){
		try {
			//测试mac F4-6D-04-36-65-DF
			return loginService.activateStation(stationId, activationCode, stationMac);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("activate error in "+stationId+"  exception="+e.toString(),e);
		}
		return RESPONSE_CODE_SERVER_ERROR;
	}
}
